﻿using System;
using Autodesk.Revit.UI;
using HyMaterialStatistic;

namespace ElectricMaterialStatistic
{
	public class ElectricRequestHandler : GridRequestHandlerParent
	{
		public override string GetName()
		{
			return "Hvac Material Statistic Grid";
		}

		public override void Execute(UIApplication uiapp)
		{
			try
			{
				DlgElectircFilter dlgElectircFilter = GridApplication.m_dlgMainSet.m_dlgFilter as DlgElectircFilter;
				switch (base.Request.Take())
				{
				case GridRequestId.None:
					return;
				case GridRequestId.Event1:
					dlgElectircFilter.treeViewSystem_AfterSelect();
					break;
				case GridRequestId.SelectArea:
					dlgElectircFilter.SelectStatisticArea();
					break;
				case GridRequestId.FilterOk:
					if (dlgElectircFilter.btnOk_Click())
					{
						GridApplication.m_dlgMainSet.Show();
					}
					else
					{
						dlgElectircFilter.Show();
					}
					break;
				case GridRequestId.FilterCancel:
					dlgElectircFilter.Hide();
					GridApplication.m_dlgMainSet.Show();
					break;
				case GridRequestId.MainDraw:
					GridApplication.m_dlgMainSet.btnDraw_Click();
					break;
				case GridRequestId.MainExport:
					GridApplication.m_dlgMainSet.btnExcel_Click();
					break;
				}
			}
			catch
			{
				GridApplication.m_dlgMainSet.Close();
			}
		}
	}
}
